package com.imooc.Thread.TicketsDemo;

/**
 * Created by Administrator on 2017/7/17.
 */
class MyThread extends Thread {

    private Integer ticketsCount = 5;   //五张票
    private String name;    //窗口、线程的名字

    public MyThread(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        while(ticketsCount > 0) {
            System.out.println(name + "买了一张票，剩余票数为：" + --ticketsCount);
        }
    }
}

public class TicketsThread {

    public static void main(String[] args) {
        MyThread mt1 = new MyThread("窗口1");
        MyThread mt2 = new MyThread("窗口2");
        MyThread mt3 = new MyThread("窗口3");
        mt1.start();
        mt2.start();
        mt3.start();
    }

}
